package com.ymatou.iapi.im.testcase;

import com.ymatou.iapi.im.parameter.SendCommentBean;
import com.ymatou.iapi.im.service.SendCommentCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymttest.business.service.ImCallService;
import com.ymttest.utils.YMTDateUtil;
import org.junit.*;
import org.junit.experimental.categories.Category;

/**
*发送评论
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_SendComment{
	private static SendCommentBean sendcommentBean;
	private static SendCommentCall sendcommentCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("发送评论");
	}

	@Before
	public void caseUp() {
		sendcommentBean=new SendCommentBean();
		sendcommentCall=new SendCommentCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(sendcommentCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_SendComment_001() {
		Logger.start(true,"发送评论，用户合法");
		try {
			sendcommentBean = ImCallService.initSendComment();
			sendcommentCall.setData(sendcommentBean);
			sendcommentCall.callService();			
			Logger.verifyEquals("200",sendcommentCall.getString("Status"),"Status");

			Logger.comment("验证数据库");
//			ImDefaultWapper im = new ImDefaultWapper();
//			Map sqlmap = im.selectComment(ObjId,ToUserId).get(0);
//			Logger.verifyEquals(sendcommentBean.getMessage(),sqlmap.get("Message").toString(),"验证Message");
//			Logger.verifyEquals(sendcommentBean.getObjId(),sqlmap.get("ObjId").toString(),"验证ObjId");
//			Logger.verifyEquals(sendcommentBean.getObjLogo(),sqlmap.get("ObjLogo").toString(),"ObjLogo");
//			Logger.verifyEquals(sendcommentBean.getObjType(),Integer.parseInt(sqlmap.get("ObjType").toString()),"ObjType");
//			Logger.verifyEquals(sendcommentBean.getToUserId(),Integer.parseInt(sqlmap.get("ToUserId").toString()),"ToUserId");
//			Logger.verifyEquals(sendcommentBean.getSenderUserId(),Integer.parseInt(sqlmap.get("FromUserId").toString()),"FromUserId");
//
//			Logger.comment("验证Redis");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}


	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_SendComment_002() {
		Logger.start(true,"发送评论，用户不合法");
		try {
			int SenderUserId = 947479497;
			sendcommentBean.setSenderUserId(SenderUserId);
			int ToUserId = 3383;
			sendcommentBean.setToUserId(ToUserId);
			sendcommentBean.setMessage("你好，星期六"+YMTDateUtil.getBeforeOrNextMunite(1));
			String ObjId = "test" + YMTDateUtil.getBeforeOrNextMunite(1);
			sendcommentBean.setObjId(ObjId);
			sendcommentBean.setObjType(1);
			sendcommentBean.setObjLogo("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401_n_w_l.jpg");
			sendcommentBean.setPushTitle("这个好不好用！");
			sendcommentCall.setData(sendcommentBean);
			sendcommentCall.callService();
			sendcommentCall.setData(sendcommentBean);
			sendcommentCall.callService();			
			Logger.verifyEquals("406",sendcommentCall.getString("Status"),"验证Status");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}